package ym.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import ym.mapper.CostMapper;
import ym.pojo.Cost;

import java.util.List;

@DubboService
public class CostServiceImpl implements CostService {
    @Autowired
    private CostMapper costMapper;

    @Override
    public void add(Cost cost) {
        costMapper.insert(cost);
    }

    @Override
    public void update(Cost cost) {
        costMapper.updateById(cost);
    }

    @Override
    public void delete(Integer id) {
        costMapper.deleteById(id);
    }

    @Override
    public Cost findById(Integer id) {
        return costMapper.selectById(id);
    }

    @Override
    public List<Cost> findAll() {
        return costMapper.selectList(null);
    }

    @Override
    public Page<Cost> search(String search, int page, int size) {
        QueryWrapper<Cost> queryWrapper = new QueryWrapper<>();
        if (search != null) {

        }
        return costMapper.selectPage(new Page(page, size), queryWrapper);
    }
}
